<?php
/**
 ***** 扶摇而上、抱守本真 ******
 * @author Dana
 * @Date 2021/6/7
 */

class Lisa
{
    public function name()
    {
        return 'Lisa';
    }

    protected function age(){
        return 22;
    }

    private  function weight(){
        return 95;
    }

    private static function eat(){
        return 1;
    }
}

$reflectionClass = new ReflectionClass('Lisa');
$ageMethod = $reflectionClass->getMethod('age');
$ageMethod->setAccessible(true);
// 执行反射方法
$age = $ageMethod->invoke($reflectionClass->newInstance());
var_dump($age);//2

$eatMethod = $reflectionClass->getMethod('eat');
$eatMethod->setAccessible(true);
$eat = $eatMethod->invoke(null);
var_dump($eat);// 1





